package org.dtrd.config.wechat.entity.bean.officialaccount.template;

import lombok.Data;
import org.dtrd.common.util.DateUtils;
import org.dtrd.config.wechat.config.WechatUtil;
import org.dtrd.config.wechat.entity.bean.officialaccount.WechatOaTemplateMsg;
import org.dtrd.config.wechat.entity.bean.officialaccount.WechatTemplateMiniProgram;

/**
 * 医生填写建议
 *
 * @author xiao
 * @date 2022/8/7 10:14 PM
 */
@Data
public class SuggestMsg extends WechatOaTemplateMsg {

    /**
     * 建议内容
     */
    private String suggestContent;


    public static final class SuggestMsgBuilder {

        private SuggestMsg suggestMsg;

        private SuggestMsgBuilder() {
            suggestMsg = new SuggestMsg();
        }

        public static SuggestMsgBuilder singleInstance() {
            return new SuggestMsgBuilder();
        }

        public SuggestMsgBuilder withMsgTitle(String msgTitle) {
            suggestMsg.setMsgTitle(msgTitle);
            return this;
        }

        public SuggestMsgBuilder withUrl(String url) {
            suggestMsg.setUrl(url);
            return this;
        }

        public SuggestMsgBuilder withRemark(String remark) {
            suggestMsg.setRemark(remark);
            return this;
        }

        public SuggestMsgBuilder withMsgTime(String msgTime) {
            suggestMsg.setMsgTime(msgTime);
            return this;
        }

        public SuggestMsgBuilder withReceiverOpenIdArray(String[] receiverOpenIdArray) {
            suggestMsg.setReceiverOpenIdArray(receiverOpenIdArray);
            return this;
        }

        public SuggestMsgBuilder withSuggestContent(String suggestContent) {
            suggestMsg.setSuggestContent(suggestContent);
            return this;
        }

        public SuggestMsg build() {
            return suggestMsg;
        }

        /**
         * 医生给患者添加饮食建议
         *
         * @param suggestContent
         * @param patientId
         * @return
         */
        public SuggestMsg buildDoctorDietSuggest(String suggestContent, Integer patientId) {
            this.withMsgTitle("医生为您的饮食提出了建议，请及时查看！").withSuggestContent(suggestContent)
                    .withMsgTime(DateUtils.formatDate(DateUtils.date_sdf_wz.get().toPattern()))
                    .withRemark("点击查看详情");
            WechatTemplateMiniProgram miniprogram = new WechatTemplateMiniProgram("/pages/checkinRecordsDetail/checkinRecordsDetail?patientId=" + patientId, WechatUtil.getClientId());
            suggestMsg.setMiniProgram(miniprogram);
            return this.build();
        }
    }
}
